<template>
	<view>
		<scroll-view scroll-y style="height: 100%;width: 100%;">
			<view class="scroll-items">
				<radio-group class="block" @change="StockChange">
					<view class="cu-list menu text-left">
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">浏览</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsBill=='√'" :checked="orderName.IsBill=='√'" :index="0"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">引验</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsCheck =='√'" :checked="orderName.IsCheck =='√'" :index="1"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">新增</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsBill_AddNew =='√'" :checked="orderName.IsBill_AddNew =='√'" :index="2"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">修改</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsBill_Change =='√'" :checked="orderName.IsBill_Change =='√'" :index="3"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">审核</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsBill_Check =='√'" :checked="orderName.IsBill_Check =='√'" :index="4"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">单价只读</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsPriceReadOnly =='√'" :checked="orderName.IsPriceReadOnly =='√'" :index="5"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">单价选择</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsPriceSelect =='√'" :checked="orderName.IsPriceSelect =='√'" :index="6"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">条码唯一</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsBarCodeOnly =='√'" :checked="orderName.IsBarCodeOnly =='√'" :index="7"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">一码多品</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsBarCodes_Select =='√'" :checked="orderName.IsBarCodes_Select =='√'" :index="8"></jiuaiCheckbox>
							</label>
						</view>
						<view class="cu-item" >
							<label class="flex justify-between align-center flex-sub">
								<view class="title1" style="flex-direction:column">数量只能为1</view>
								<jiuaiCheckbox @change='changeBox' :value="orderName.IsNumberReadOnly =='√'" :checked="orderName.IsNumberReadOnly =='√'" :index="9"></jiuaiCheckbox>
							</label>
						</view>
						
					</view>
				</radio-group>
				<view class="padding flex flex-direction">
					<button class="cu-btn bg-grey lg" @tap="bc()">保存</button>
				</view>	
			</view>
		</scroll-view>
	</view>
</template>
<script>
import jiuaiCheckbox from "@/components/jiuai-checkbox.vue";
import * as Api from '@/syApis/sypower/sypower.js';
	export default {
		components: {
			jiuaiCheckbox
		},
		data(){
			return {
				UserID:"",
				orderName:{},
				radio: '',
				gbtzList: [{
						name: "浏览",
						checked:true,
					},
					{
						name: "引验",
						checked:true,
					},
					{
						name: "新增",
						checked:true,
					},
					{
						name: "修改",
						checked:true,
					},
					{
						name: "审核",
						checked:true,
					},
					{
						name: "单价只读",
						checked:true,
					},
					{
						name: "单价选择",
						checked:true,
					},
					{
						name: "条码唯一",
						checked:true,
					},
					{
						name: "一码多品",
						checked:true,
					},
					{
						name: "数量只能为1",
						checked:true,
					},
					{
						name: "打印",
						checked:true,
					},
					{
						name: "隐藏单价",
						checked:true,
					}
				]
			}
		},
		onLoad(options){
			this.orderName = JSON.parse(options.PDA_ModuleItem);
			this.BillName = options.BillName;
		},
		methods: {
			bc(){
				
				console.log(this.orderName);
				let Save_M_Data_Json = {
					'IsBill' :this.orderName.IsBill,
					'IsCheck'  :this.orderName.IsCheck,
					'IsBill_AddNew'	:this.orderName.IsBill_AddNew,
					'IsBill_Change'	:this.orderName.IsBill_Change,
					'IsBill_Check' :this.orderName.IsBill_Check,
					'IsPriceReadOnly' :this.orderName.IsPriceReadOnly,		
					'IsPriceSelect':this.orderName.IsPriceSelect,				
					'IsBarCodeOnly' :this.orderName.IsBarCodeOnly,				
					'IsBarCodes_Select' :this.orderName.IsBarCodes_Select,
					'IsNumberReadOnly':this.orderName.IsNumberReadOnly	,	
					'IsPrint':this.orderName.IsPrint,
					'IsNotShowPrice':this.orderName.IsNotShowPrice
				}
				let data = {
					Save_M_Data_Json:JSON.stringify(Save_M_Data_Json),
					UserID:this.orderName.UserID,
					BillName:this.orderName.ModuleName
				}
				Api.SaveBillRoot(data,function(res){
					// uni.hideLoading();
					 if(res.state){
						  if(res.data.ErrorMsg=='获取登录信息失败'){
							  
						  }else if(res.data.ErrorMsg!=""){
							  Api.showTip(res.ErrorMsg);
						  }else{
							  Api.showTip("保存成功");
						  }
					 }else{
						 Api.showTip("服务器开小差了");
					 }
				});
			},
			changeBox(e){
				console.log(e);
				let index = parseInt(e.detail.index);
				
				let value = e.detail.value;
				console.log(e.detail.value);
				if(index==0){
					if(value){
						this.orderName.IsBill = '';
					}else{
						this.orderName.IsBill = '√';
					}
				}else if(index==1){
					if(value){
						this.orderName.IsCheck = '';
					}else{
						this.orderName.IsCheck = '√';
					}
				}else if(index==2){
					if(value){
						this.orderName.IsBill_AddNew = '';
					}else{
						this.orderName.IsBill_AddNew = '√';
					}
				}else if(index==3){
					if(value){
						this.orderName.IsBill_Change = '';
					}else{
						this.orderName.IsBill_Change = '√';
					}
				}else if(index==4){
					if(value){
						this.orderName.IsBill_Check = '';
					}else{
						this.orderName.IsBill_Check = '√';
					}
				}else if(index==5){
					if(value){
						this.orderName.IsPriceReadOnly = '';
					}else{
						this.orderName.IsPriceReadOnly = '√';
					}
				}else if(index==6){
					console.log("进去了6");
					if(value){
						this.orderName.IsPriceSelect = '';
					}else{
						this.orderName.IsPriceSelect = '√';
					}
				}else if(index==7){
					if(value){
						this.orderName.IsBarCodeOnly = '';
					}else{
						this.orderName.IsBarCodeOnly = '√';
					}
				}else if(index==8){
					console.log("进去了8");
					if(value){
						this.orderName.IsBarCodes_Select = '';
					}else{
						this.orderName.IsBarCodes_Select = '√';
					}
				}
				else if(index==9){
					console.log("进去了8");
					if(value){
						this.orderName.IsNumberReadOnly = '';
					}else{
						this.orderName.IsNumberReadOnly = '√';
					}
				}
				console.log(this.orderName);
			}
		}
	}
</script>
<style>
.add-btn{
		position: fixed;
		left: 30upx;
		right: 30upx;
		bottom: 16upx;
		z-index: 95;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 690upx;
		height: 80upx;
		font-size: 32upx;
		color: #fff;
		background-color: rgba(34,164,255,1.0);
		border-radius: 10upx;
		box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);		
	}
</style>
